package com.example.page.data.repository

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.example.page.data.model.Quotes
import com.example.page.data.pagination.QuotesPagingSource
import com.example.page.data.remote.api.QuotesService
import kotlinx.coroutines.flow.Flow

class QuotesRepositoryImpl(
    private val api: QuotesService
) : QuotesRepository {

    override fun getQuotes(): Flow<PagingData<Quotes>> {
        return Pager(
            config = PagingConfig(pageSize = 20, enablePlaceholders = false),
            pagingSourceFactory = {
                QuotesPagingSource(api)
            }
        ).flow
    }

}